package com.sxkiler.demo.controller;

import cn.hutool.core.date.DateUtil;
import com.sxkiler.demo.utils.ResUtils;
import com.sxkiler.demo.vo.ResVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/httptest")
public class HttpTestController {


    @RequestMapping("/longConn")
    public ResVo longConn(@RequestParam(name = "sleepTime") String sleepTime) throws InterruptedException {
        long startTime = System.currentTimeMillis();
        System.out.println("请求开始执行 at "  + DateUtil.date());
        Thread.sleep(Long.valueOf(sleepTime));
        long endTime = System.currentTimeMillis();
        System.out.println("参数,"+sleepTime+",执行时间"+(endTime-startTime));
        return ResUtils.success();
    }
}
